﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SISGEZATBZVisual.BusinessEntities;

namespace SISGEZATBZVisual.Repository.Mapping
{
    public class CursoDocenteMap:EntityTypeConfiguration<CursoDocente>
    {
        public CursoDocenteMap()
        {
            this.HasKey(c => new {  c.IdCurso, c.IdDocente });

            //propiedades

            this.Property(r => r.FechaInicio)
                .IsRequired();

            this.Property(r => r.FechaFin)
               .IsRequired();

            this.Property(c => c.Seccion)
            .HasMaxLength(200)
            .IsRequired();

            //table
            this.ToTable("Curso Docente");

            //Relaciones
            this.HasRequired(r => r.Docente)
                .WithMany()
                .HasForeignKey(r => r.IdDocente)
                .WillCascadeOnDelete(false);
            
             this.HasRequired(c => c.Curso)
                 .WithMany()
                 .HasForeignKey(c => c.IdCurso)
                  .WillCascadeOnDelete(false);

 
        }
    }
}
